package org.example.mall.Pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;

@Data//自动加载setter、getter和tostring方法
@AllArgsConstructor
@NoArgsConstructor
@Component("Result")//相当于bean标签，括号内相当于id
public class Result<T> {
    private Integer code;//响应码，1代表成功，0代表失败
    private String msg;//响应信息，描述字符串
    private T data;//返回的数据
    public static Result success(){//增删改成功响应
        return new Result(0,"success",null);
    }
    public static <E> Result<E> success(E data){//查询成功响应
        return new Result<>(0,"success",data);
    }
    public static Result error(String msg){//失败响应
        return new Result(0,msg,null);
    }
}
